/**
 *
 *  array 复制
 * @param e
 * @returns {*}
 */
function e(e) {
    if (Array.isArray(e)) {
        for (var o = 0, t = Array(e.length); o < e.length; o++) t[o] = e[o];
        return t;
    }
    return Array.from(e);
}

/**
 *
 * @param e
 * @returns {Function}
 */
var o = function (e) {
        var o = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : wx;
        return function () {
            var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {};
            return new Promise(function (n, r) {
                o[e](Object.assign({}, t, {
                    success: n,
                    fail: r
                }));
            });
        };
    },
    t = {
        net: ["request", "uploadFile", "downloadFile", "connectSocket", "onSocketOpen", "onSocketError", "sendSocketMessage", "onSocketMessage", "closeSocket", "onSocketClose"],
        dataCache: ["setStorage", "getStorage", "setStorageSync", "getStorageSync", "getStorageInfo", "removeStorage", "clearStorage"],
        location: ["getLocation", "chooseLocation", "openLocation"],
        device: ["getNetworkType"],
        userface: ["showToast", "showLoading", "hideToast", "hideLoading", "showModal", "showActionSheet", "navigateTo", "redirectTo", "reLaunch", "switchTab", "navigateBack"],
        media: ["getImageInfo"],
        openAPI: ["login", "checkSession", "authorize", "getUserInfo", "requestPayment", "getSetting", "openSetting"]
    },
    n = [];

for (var r in t) n = [].concat(e(n), e(t[r]));

var a = n.reduce(function (e, t) {
    return "[object String]" === Object.prototype.toString.call(t) ? e[t] = o(t) : e[t.name] = o(t.name, t.thisArg),
        e;
}, {});

module.exports = a;